package com.gee.spring.boot.oauth2.auth.controller;


import com.gee.spring.boot.oauth2.auth.entity.User;
import com.gee.spring.boot.oauth2.auth.service.UserService;
import com.gee.spring.boot.oauth2.common.util.result.Result;
import com.gee.spring.boot.oauth2.common.util.result.ResultCode;
import com.gee.spring.boot.oauth2.common.util.result.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author gee
 * @since 2020-03-22
 */
@RestController
@RequestMapping("/user")
public class UserController {
    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    public UserService userService;

    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable("id") String id){
            User user = userService.getById(id);
            if (user == null){
                return ResultUtil.error(ResultCode.NULL_DATA);
            }
            return ResultUtil.successWithData(user);
    }
}